﻿using PPSMS_DAL;
using PPSMS_Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace PPSMS_BLL
{
    public class StationStatus_BLL
    {
        private StationStatus_DAL _stationStatus_DAL = new();

        public void Insert(StationStatus stationStatus)
        {
            _stationStatus_DAL.Insert(stationStatus);
        }

        /// <summary>
        /// 查询电站状态表中的逆变器数量
        /// </summary>
        /// <returns></returns>
        public long SelectNewest()
        {
            long count = 0;
            var StationStatus = _stationStatus_DAL.SelectNewest();
            foreach(var station in StationStatus)
            {
                count = (long)station.InverterCount;
            }
            return count;
        }

        /// <summary>
        /// 修改电站状态表中逆变器数量
        /// </summary>
        /// <param name="tag">tag等于true为加，tag等于false为减</param>
        public void UpdateCount(bool tag)
        {
             _stationStatus_DAL.UpdateNewest(tag);
        }
    }
}
